/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @signatureAlgorithm = 'v2';
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('sgx-dcap-server', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model GetQeIdentityRequest {
  acsHost?: string(name='AcsHost'),
  clientVpcId?: string(name='ClientVpcId'),
}

model GetQeIdentityResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: string(name='body'),
}

async function getQeIdentityWithOptions(request: GetQeIdentityRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetQeIdentityResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.acsHost)) {
    query['AcsHost'] = request.acsHost;
  }
  if (!Util.isUnset(request.clientVpcId)) {
    query['ClientVpcId'] = request.clientVpcId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetQeIdentity',
    version = '2020-07-26',
    protocol = 'HTTPS',
    pathname = `/sgx/certification/v3/qe/identity`,
    method = 'GET',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function getQeIdentity(request: GetQeIdentityRequest): GetQeIdentityResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getQeIdentityWithOptions(request, headers, runtime);
}

model GetQveIdentityRequest {
  acsHost?: string(name='AcsHost'),
  clientVpcId?: string(name='ClientVpcId'),
}

model GetQveIdentityResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: string(name='body'),
}

async function getQveIdentityWithOptions(request: GetQveIdentityRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetQveIdentityResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.acsHost)) {
    query['AcsHost'] = request.acsHost;
  }
  if (!Util.isUnset(request.clientVpcId)) {
    query['ClientVpcId'] = request.clientVpcId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetQveIdentity',
    version = '2020-07-26',
    protocol = 'HTTPS',
    pathname = `/sgx/certification/v3/qve/identity`,
    method = 'GET',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function getQveIdentity(request: GetQveIdentityRequest): GetQveIdentityResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getQveIdentityWithOptions(request, headers, runtime);
}

model GetTcbInfoRequest {
  acsHost?: string(name='AcsHost'),
  clientVpcId?: string(name='ClientVpcId'),
  fmspc?: string(name='fmspc', example='00706a100000'),
}

model GetTcbInfoResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: string(name='body'),
}

async function getTcbInfoWithOptions(request: GetTcbInfoRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetTcbInfoResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.acsHost)) {
    query['AcsHost'] = request.acsHost;
  }
  if (!Util.isUnset(request.clientVpcId)) {
    query['ClientVpcId'] = request.clientVpcId;
  }
  if (!Util.isUnset(request.fmspc)) {
    query['fmspc'] = request.fmspc;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetTcbInfo',
    version = '2020-07-26',
    protocol = 'HTTPS',
    pathname = `/sgx/certification/v3/tcb`,
    method = 'GET',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function getTcbInfo(request: GetTcbInfoRequest): GetTcbInfoResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getTcbInfoWithOptions(request, headers, runtime);
}

model PckCrlRequest {
  acsHost?: string(name='AcsHost'),
  clientVpcId?: string(name='ClientVpcId'),
  ca?: string(name='ca', example='platform'),
}

model PckCrlResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: string(name='body'),
}

async function pckCrlWithOptions(request: PckCrlRequest, headers: map[string]string, runtime: Util.RuntimeOptions): PckCrlResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.acsHost)) {
    query['AcsHost'] = request.acsHost;
  }
  if (!Util.isUnset(request.clientVpcId)) {
    query['ClientVpcId'] = request.clientVpcId;
  }
  if (!Util.isUnset(request.ca)) {
    query['ca'] = request.ca;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'PckCrl',
    version = '2020-07-26',
    protocol = 'HTTPS',
    pathname = `/sgx/certification/v3/pckcrl`,
    method = 'GET',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function pckCrl(request: PckCrlRequest): PckCrlResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return pckCrlWithOptions(request, headers, runtime);
}

model RootCaCrlRequest {
  acsHost?: string(name='AcsHost'),
  clientVpcId?: string(name='ClientVpcId'),
}

model RootCaCrlResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: string(name='body'),
}

async function rootCaCrlWithOptions(request: RootCaCrlRequest, headers: map[string]string, runtime: Util.RuntimeOptions): RootCaCrlResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.acsHost)) {
    query['AcsHost'] = request.acsHost;
  }
  if (!Util.isUnset(request.clientVpcId)) {
    query['ClientVpcId'] = request.clientVpcId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'RootCaCrl',
    version = '2020-07-26',
    protocol = 'HTTPS',
    pathname = `/sgx/certification/v3/rootcacrl`,
    method = 'GET',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function rootCaCrl(request: RootCaCrlRequest): RootCaCrlResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return rootCaCrlWithOptions(request, headers, runtime);
}

model SimplePackagePckCertRequest {
  acsHost?: string(name='AcsHost'),
  clientVpcId?: string(name='ClientVpcId'),
  cpusvn?: string(name='cpusvn', example='05050809FFFF00000000000000000000'),
  encryptedPpid?: string(name='encrypted_ppid', example='000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'),
  pceid?: string(name='pceid', example='0000'),
  pcesvn?: string(name='pcesvn', example='0D00'),
  qeid?: string(name='qeid', example='B5C869897796C3525B2163D3DE6754FA'),
}

model SimplePackagePckCertResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: string(name='body'),
}

async function simplePackagePckCertWithOptions(request: SimplePackagePckCertRequest, headers: map[string]string, runtime: Util.RuntimeOptions): SimplePackagePckCertResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.acsHost)) {
    query['AcsHost'] = request.acsHost;
  }
  if (!Util.isUnset(request.clientVpcId)) {
    query['ClientVpcId'] = request.clientVpcId;
  }
  if (!Util.isUnset(request.cpusvn)) {
    query['cpusvn'] = request.cpusvn;
  }
  if (!Util.isUnset(request.encryptedPpid)) {
    query['encrypted_ppid'] = request.encryptedPpid;
  }
  if (!Util.isUnset(request.pceid)) {
    query['pceid'] = request.pceid;
  }
  if (!Util.isUnset(request.pcesvn)) {
    query['pcesvn'] = request.pcesvn;
  }
  if (!Util.isUnset(request.qeid)) {
    query['qeid'] = request.qeid;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SimplePackagePckCert',
    version = '2020-07-26',
    protocol = 'HTTPS',
    pathname = `/sgx/certification/v3/pckcert`,
    method = 'GET',
    authType = 'Anonymous',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function simplePackagePckCert(request: SimplePackagePckCertRequest): SimplePackagePckCertResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return simplePackagePckCertWithOptions(request, headers, runtime);
}

